﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using 纸片人.CalculateControls;

//https://go.microsoft.com/fwlink/?LinkId=234236 上介绍了“用户控件”项模板

namespace 纸片人.win2dEffectControl
{
    public sealed partial class Matrix3x2Control : UserControl
    {


        public Matrix3x2 Matrix3x2
        {
            get { return (Matrix3x2)GetValue(Matrix3x2Property); }
            set { SetValue(Matrix3x2Property, value); }
        }

        // Using a DependencyProperty as the backing store for Matrix3x2.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty Matrix3x2Property =
            DependencyProperty.Register("Matrix3x2", typeof(Matrix3x2), typeof(Matrix3x2Control), new PropertyMetadata(new Matrix3x2(),Matrix3x2Callback));

        private static void Matrix3x2Callback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            
        }

        public delegate void Matrix3x2ChangedHeader(Matrix3x2Control sender, Matrix3x2 value);
        public event Matrix3x2ChangedHeader Matrix3x2Changed;
        public event Matrix3x2ChangedHeader Matrix3x2Changing;

        public Matrix3x2Control()
        {
        
            this.InitializeComponent();
            
        }

       

        private void TextBoxSlider_ValueChanged(TextBoxSlider sender, double newValue, double oldValue)

        {
            //var translate = Matrix3x2.CreateTranslation((float)tx.Value, (float)ty.Value);
            //var scale = Matrix3x2.CreateScale((float)sx.Value, (float)sy.Value);
            //var skew = Matrix3x2.CreateSkew((float)kx.Value, (float)ky.Value);
            //var rotato = Matrix3x2.CreateRotation((float)mr.Value );
            //Matrix3x2 = scale * skew * rotato * translate;
            //Matrix3x2Changed?.Invoke(this, Matrix3x2);
        }

        private void tx_ValueChange(TextBoxSlider sender, double newValue)
        {
            //var translate = Matrix3x2.CreateTranslation((float)tx.Value, (float)ty.Value);
            //var scale = Matrix3x2.CreateScale((float)sx.Value, (float)sy.Value);
            //var skew = Matrix3x2.CreateSkew((float)kx.Value, (float)ky.Value);
            //var rotato = Matrix3x2.CreateRotation((float)mr.Value);

            //Matrix3x2 = scale * skew * rotato * translate;
            //Matrix3x2Changing?.Invoke(this, Matrix3x2);
        }

        public void SetMatrix3x2(Matrix3x2 matrix)
        {
            
        }
    }
}
